package com.pubinfo.passbook.data.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.pubinfo.passbook.common.entity.TBankApplyReceipt;
import com.pubinfo.passbook.common.entity.TFileEnclosureFtp;
import com.pubinfo.passbook.common.entity.TFileInfo;
import com.pubinfo.passbook.common.model.dto.file.ArtificialFileParam;
import com.pubinfo.passbook.common.model.dto.file.ArtificialParam;
import com.pubinfo.passbook.common.model.dto.file.FileListParam;
import com.pubinfo.passbook.common.model.dto.open.WiteoffAttchment;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

public interface TFileInfoService extends IService<TFileInfo> {


  TFileEnclosureFtp saveFile(TFileInfo tFileInfo);

  TFileEnclosureFtp saveTFileEnclosure(MultipartFile file) throws IOException;

  Boolean saveArtificialFile(ArtificialFileParam artificialFileParam) throws IOException;

  //根据条件查询未被软删除的文件
  IPage<TFileInfo> selectFileInfoByFileListParam(FileListParam fileListParam);

  //根据人工报账的id获取相关附件
  List<TFileInfo> selectByArtificialId(String artificialId);

  //上传人工审核使用的票据
  Boolean uploadArtificial(ArtificialParam artificialParam,String artificialId,String path) throws IOException;

  //上传人工审核使用的票据,默认地址
  Boolean uploadArtificial(ArtificialParam artificialParam,String artificialId) throws IOException;

  //上传指定类型的附件
  Boolean uploadAppendixByType(List<MultipartFile> multipartFiles,Integer type,String id,String path) throws IOException;

  //上传指定类型的附件,默认位置
  Boolean uploadAppendixByType(List<MultipartFile> multipartFiles,Integer type,String id) throws IOException;

  //上传指定类型相关文件
  Boolean uploadFileByType(List<MultipartFile> multipartFiles,Integer type,String id,String path) throws IOException;

  //上传指定类型文件,默认位置
  Boolean uploadFileByType(List<MultipartFile> multipartFiles,Integer type,String id) throws IOException;

  //系统上传文件,不上传ftp
  Boolean uploadFile(String acct, MultipartFile file, String name, String passbookId, String path) throws IOException;
  
  //根据位置上传,自定义命名和位置
  Boolean uploadFile(MultipartFile file, String name, String path) throws IOException;
  
  //上传文件，自定义命名
  Boolean uploadFile(MultipartFile file, String name) throws IOException;
  
  //上传文件，默认位置
  Boolean uploadFile(MultipartFile file) throws IOException;
  
  /**
   * 批量上传文件后，返回ftp地址列表
   *
   * @param files
   * @param attchments
   * @return
   */
  List<WiteoffAttchment> uploadOpenFile(List<WiteoffAttchment> attchments);
  
  //批量上传文件
  Boolean uploadFile(List<MultipartFile> multipartFiles, String path) throws IOException;
  
  //批量上传文件,默认位置
  Boolean uploadFile(List<MultipartFile> multipartFiles) throws IOException;
  
  //软删除文件
  Boolean softDelete(List<String> id);
  
  void acctDownload(HttpServletRequest request, HttpServletResponse response, String id) throws UnsupportedEncodingException;

  void acctDownloadZip(HttpServletRequest request, HttpServletResponse response, List<String> id) throws IOException;

  List<TFileInfo> saveInvoiceFile(byte[] fileData, String date,String nsrsbh) throws Exception;

  /**
   * 将所有未上传到ftp的电子票据上传
   * @return
   * @throws IOException
   */
  Boolean uploadPdf2Ftp() throws IOException;

  List<TFileInfo> saveBankFile(TBankApplyReceipt tBankApplyReceipt) throws Exception;

}
